package cn.edu.heuet.bnve.activity.SettingActivity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;

import com.xuexiang.xui.widget.grouplist.XUICommonListItemView;
import com.xuexiang.xui.widget.grouplist.XUIGroupListView;

import cn.edu.heuet.bnve.R;
import cn.edu.heuet.bnve.databinding.ActivityAboutBinding;


public class AboutActivity extends AppCompatActivity {

    private ActivityAboutBinding binding;
    private XUIGroupListView mGroupListView;
    private Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_about);
        initData();
        initView();
        initEvent();
    }

    public static void show(Context context) {
        context.startActivity(new Intent(context, AboutActivity.class));
    }


    public void initData(){

    }

    public void initView(){
        mGroupListView = binding.aboutGroupListView;
        initGroupListView();

        toolbar=binding.toolbarContainer.toolbar;
        setSupportActionBar(toolbar);
        toolbar.setTitle(R.string.text_about);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId() == android.R.id.home)
        {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void initEvent(){


    }
    private void initGroupListView() {

        XUICommonListItemView item1 = mGroupListView.createItemView(
                "版本");
        item1.setTag(1);
        item1.setOrientation(XUICommonListItemView.HORIZONTAL);
        item1.setAccessoryType(XUICommonListItemView.ACCESSORY_TYPE_NONE);
        item1.setDetailText("1.0");

        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v instanceof XUICommonListItemView) {
                    int tagValue = (Integer) ((XUICommonListItemView) v).getTag();
                    switch (tagValue){
                        case 1:
                            break;
                        default:
                            break;
                    }
                }
            }
        };

        XUIGroupListView.newSection(this)
                .setTitle("软件信息")
                .addItemView(item1, onClickListener)
                .addTo(mGroupListView);
    }
}